﻿KISSY.add("fgt/map/detailMap", function (S) {
    function detailMap(option) {
        var self = this;
        self._init(option);
    }
    S.augment(detailMap, {
        _init: function (option) {
            var self = this,
                $ = S.all;

            self.containerId = option.containerId;
            self.level = option.mapLevel;
            self.lat = option.lat;
            self.lng = option.lng;
        },

        _bindMarkerEvents: function () {
            var self = this;
        },

        Show: function () {
            var self = this;

            if (typeof self.g_Map === "undefined") {
                var ll = new google.maps.LatLng(self.lat, self.lng);
                self.g_Map = new google.maps.Map(document.getElementById(self.containerId), { mapTypeId: google.maps.MapTypeId.ROADMAP, scrollwheel: true, center: ll, zoom: 10 });
                if (typeof self.level == "number") {
                    self.g_Map.setZoom(self.level);
                }
                self.g_Marker = new google.maps.Marker({ position: ll, map: self.g_Map, visible: true, icon: CONFIG["imgCDNServer"] + "static/img/map/IAMHere.png" });
                self._bindMarkerEvents();
            }
        },

        SetPosition: function (lat, lng) {
            var self = this;
            self.lat = lat;
            self.lng = lng;
            var ll = new google.maps.LatLng(self.lat, self.lng);
            self.g_Marker.setPosition(ll);
            self.g_Map.setCenter(ll);
        }
    });

    return detailMap;
});